import java.util.HashMap;
import java.util.Map;
import java.util.Set;

public class Map_Test2 {
    public static void main(String[] args) {
        Map<String, Integer> map = new HashMap<>();
        map.put("小张",25);
        map.put("小刘",24);
        map.put("小王",23);
        map.put("小赵",22);
        // 获取map集合的所有键
        Set<String> keys = map.keySet();
        // 根据键获取值
        for (String key : keys){
            Integer value = map.get(key);
            System.out.println(key+"---"+value);
        }
        System.out.println("-------------------------");
        Set<Map.Entry<String, Integer>> entries = map.entrySet();
        for (Map.Entry<String, Integer> entrie : entries){
            System.out.println(entrie.getKey());
            System.out.println(entrie.getValue());
        }
        System.out.println("------------------");
        map.forEach((k,v) ->{
            System.out.println(k+"---"+v);
        });
    }
}
